{% import "components/paginator.html" as paginator with context %}
{% extends "layout/basic.html" %}
{{ set(UiContext, 'tdoc', tdoc) }}
{{ set(UiContext, 'tsdoc', tsdoc) }}
{% set type = 'homework' if tdoc.rule == 'homework' else 'contest' %}

{% block content %}
<div class="row"><div class="medium-12 columns scoreboard--{{ tdoc.rule }}">
  <div class="section visible">
    <div class="section__header">
      {%- for ext in ['HTML', 'CSV', 'Ghost'] -%}
        <a class="button" target="_blank" href="{{ url(type + '_scoreboard_view', tid=tdoc.docId, view=ext.toLowerCase()) }}">
          <span class="icon icon-download"></span> {{ _('Export as {0}').format(ext) }}
        </a>
      {%- endfor -%}
      {% for id, name in availableViews %}{% if not ['html', 'csv', 'default', 'ghost'].includes(id) %}
        <a class="button" target="_blank" href="{{ url(type + '_scoreboard_view', tid=tdoc.docId, view=id) }}">
          <span class="icon icon-copy"></span> {{ _(name) }}
        </a>
      {% endif %}{% endfor %}
      {% if model.contest.isDone(tdoc) and tdoc.lockAt and handler.user.own(tdoc) and not tdoc.unlocked %}
        <form method="POST">
          <input type="hidden" name="operation" value="unlock">
          <button type="submit" class="button">
            <span class="icon icon-feeling-lucky"></span> {{ _('Unlock scoreboard') }}
          </button>
        </form>
      {% endif %}
      <div class="section__tools">
        <select class="select filter" name="list">
          <option value="all">{{ _('All Users') }}</option>
          <option value="star">{{ _('Starred Users') }}</option>
          <option value="rank">{{ _('Ranked Users') }}</option>
          {% for group in groups %}
            <option value="{{ group.uids.join(',') }}">{{ group.name }}</option>
          {% endfor %}
        </select>
      </div>
    </div>
    {% include "partials/scoreboard.html" %}
  </div>
</div></div>
{% endblock %}
